# 使用 auto() 自动生成枚举值
from enum import Enum, IntEnum, auto

class Weekday(IntEnum):
    TUE = auto()
    WED = auto()

print(Weekday.TUE.value)  
print(Weekday.WED.value)  


# 自定义生成逻辑：重写 _generate_next_value_ 方法：
class CustomEnum(Enum):
    def _generate_next_value_(name, start, count, last_values):
        # 将 name 转换为字符串后再调用 lower()
        return f"{str(name).lower()}_{count}"

class Status(CustomEnum):
    PENDING = auto()  # "pending_1"
    APPROVED = auto() # "approved_2"



class HTTPStatus(Enum):
    OK = (200, "Success")
    NOT_FOUND = (404, "Not Found")

    def __init__(self, code, desc):
        self._value_ = code  # 必须赋值给 _value_
        # 使用 _desc 作为私有属性名称来存储描述信息
        self._desc = str(desc)    # 自定义私有属性

print(HTTPStatus.OK._desc)  # 输出: "Success"


# 枚举迭代
from enum import Enum

class Color(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3
print("Color Enum Members:")
for color in Color:
    print(color)

